<template>
	<view class="detailsPage searchResults customTitleBar" :style="{borderTopWidth:statusBarHeight}">
		<view class="custom-status-bar" :style="{backgroundColor: customTitleBarBg,height:statusBarHeight}"></view>
		<view class="custom-nav-bar" :style="{top:statusBarHeight,backgroundColor: customTitleBarBg,}">
			<text class="title-green">搜索</text>
		</view>
		<view class="gap"></view>
	<view class="search-bar">
		<view class="search-form">
			<input type="text" placeholder="搜索关键字查询" v-model="searchInput" confirm-type="search" @confirm="doFind">
			<view class="btn-clear" @click.stop="clearInput" v-show="searchInput !=''">清除</view>
		</view>
	</view>
		<view class="container-wrap">
			<view class="container list">
				<view class="list-item" v-for="(item, index) in bloodImageList"><image :src="baseUrl+item.imageUrl"></image></view>
			</view>
		</view>
		<!-- 底部导航s -->
		<view class="menu-bar">
			<view class="menu-bar-item" @click="toHome"><view class="icon icon-home"></view><text>首页</text></view>
			<view class="menu-bar-item" @click="toPersonalCenter"><view class="icon icon-me"></view><text>我的</text></view>
		</view>
		<!-- 底部导航s -->
	</view>
</template>

<script>
	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'
	import { getBloodImageList} from '@/common/api.js';
	import config from '@/common/config'
	export default {
		data() {
			return {
				customTitleBarBg: 'rgba(250,250,250,1)',
				statusBarHeight: statusBarHeight,
				searchInput: '',
				bloodImageList:[],
				baseUrl:null,
			}
		},onLoad(option) {
			this.searchInput=option.searchInput;
			this.baseUrl=config.baseUrl;
			
		},onShow(){
			this.getBloodImageList();
		},
		methods: {
			doFind(){
				this.getBloodImageList();
			},
			clearInput() {
				this.searchInput = '';
			},
			toSearchResults() {
				uni.redirectTo({
					url: '../searchResults/searchResults',
				});
			},
			toHome() {
				uni.redirectTo({
					url: '../index/index',
				});
			},
			toPersonalCenter() {
				uni.redirectTo({
					url: '../personalCenter/personalCenter',
				});
			},getBloodImageList(){
				let bloodType="";
				
				// get请求
				getBloodImageList({params:{ 'bloodType':bloodType,'searchInput':this.searchInput}}).then(data => {
					this.bloodImageList=data;
				}).catch(() =>{
					
				})
			},
			
		}
	}
</script>

<style>
	page{background-color: #fff;}
</style>